Tomáš Pospíšek's Notizblock
Installing etckeeper with ansible
The following is for dpkg
based systems only:
- name: install etckeeper and git
package:
name: "{{ item }}"
state: present
with_items:
- git
- etckeeper
- name: configure etckeeper - set git as VCS
lineinfile: "dest=/etc/etckeeper/etckeeper.conf regexp='^#(VCS=\"git\")' line='\\1' backrefs=yes"
- name: configure etckeeper - remove bzr as VCS
lineinfile: "dest=/etc/etckeeper/etckeeper.conf regexp='^(VCS=\"bzr\")' line='#\\1' backrefs=yes"
register: etckeeper_unset_bzr
- name: uninit bzr repo
command: etckeeper uninit
when: (etckeeper_unset_bzr is defined) and (etckeeper_unset_bzr is changed)
- name: purge bzr
package:
name: bzr
state: absent
when: (etckeeper_unset_bzr is defined) and (etckeeper_unset_bzr is changed)
- name: check etckeeper status
stat:
path: /etc/.git
register: git
- name: initialize etckeeper
command: etckeeper init
args:
chdir: /etc
when: not ( git.stat.isdir is defined and git.stat.isdir )
register: initialization
- name: initial etckeer commit
command: etckeeper commit "initial commit"
args:
chdir: /etc
when: initialization is defined and initialization is changed
Tomáš Pospíšek, 2018-06-07